package com.haifeng.questionbankcrud.services.impl;

import com.haifeng.questionbankcrud.dao.impl.SingleChoiceDaoImpl;
import com.haifeng.questionbankcrud.pojo.SingleChoice;
import com.haifeng.questionbankcrud.services.SingleChoiceService;

import java.util.List;

public class SingleChoiceServiceImpl implements SingleChoiceService {
    //todo service层是否做非空校验
    private SingleChoiceDaoImpl dao = new SingleChoiceDaoImpl();

    @Override
    public List<SingleChoice> selectSingleChoice(SingleChoice sc) {

        List<SingleChoice> singleChoices = null;

        if (!(sc.getPoint().isEmpty())) {
            //按照知识点查询
            singleChoices = dao.selectChoiceByPoint(sc);

        } else {
            //全部查询
            singleChoices = dao.selectAllChoice();

        }
        return singleChoices;
    }

    @Override
    public int updateSingleChoice(SingleChoice sc) {
        return dao.updateSingleChoiceById(sc);
    }

    @Override
    public int deleteSingleChoice(SingleChoice sc) {
        return dao.deleteSingleChoiceById(sc);

    }

    @Override
    public int insertSingleChoice(SingleChoice sc) {
        return dao.insertSingleChoice(sc);
    }
}
